package com.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author hfxiang
 * @class_name SpringUtil
 * @describe
 * @create_date 2022/7/15 23:55
 */
public class SpringUtil {
   private static ApplicationContext context ;
   static {
       context = new ClassPathXmlApplicationContext("Beans.xml");
   }
    public ApplicationContext getContext() {
        return context;
    }

    public static Object getBeanByName(String beanName){
        Object obj =  context.getBean(beanName);
        return obj;
    }

}
